<?php
require_once './model/works.php';
$keyword = new Works();
$keyword->table_name = "works";

?>
<?php
$max_page = 7;
                            for ($i = 1; $i <= $max_page; $i++):
                                if (($_GET["page"] == 1) || ($_GET["page"] == 2) || ($_GET["page"] == 3) || ($_GET["page"] == 4)): ?>            
                                    <?php for ($i = 1; $i <= $max_page; $i++): ?>
                                        <a href='index.php?page=<?php echo $i; ?> '><?php echo $i ?></a>
                                        <?php if ($_GET["page"] == $i): ?>
                                            <?php $keyword->begin; ?>
                                            <?php $keyword->end = PAGE; ?>
                                        <?php endif; ?>
                                    <?php endfor; ?>
                                <?php elseif (($_GET["page"] == $total / PAGE) || ($_GET["page"] == $total / PAGE - 1) || ($_GET["page"] == $total / PAGE - 2) || ($_GET["page"] == $total / PAGE - 3)): ?>        
                                    <?php for ($i = $total / PAGE - $max_page; $i <= $total / PAGE; $i++): ?>
                                        <a href='index.php?page=<?php echo $i; ?> '><?php echo $i ?></a>
                                        <?php if ($_GET["page"] == $i): ?>
                                            <?php $keyword->begin; ?>
                                            <?php $keyword->end = PAGE; ?>
                                        <?php endif; ?>
                                    <?php endfor; ?>
                                <?php else : ?>
                                    <?php for ($i = $_GET["page"] - 3; $i <= $_GET["page"] + 3; $i++): ?>
                                        <a href='index.php?page=<?php echo $i; ?> '><?php echo $i ?></a>
                                        <?php if ($_GET["page"] == $i): ?>
                                            <?php $keyword->begin; ?>
                                            <?php $keyword->end = PAGE; ?>
                                        <?php endif; ?>
                                    <?php endfor; ?>
                                <?php endif; ?> 
                            <?php endfor; ?>
?>